package cevent.source.cloudcenter.business.controller.client;/**
 * Created by Cevent on 2021/7/19.
 */

import cevent.source.cloudcenter.server.dto.PageSelectDto;
import cevent.source.cloudcenter.server.dto.ResponseDataDto;
import cevent.source.cloudcenter.server.service.ProductService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author cevent
 * @description 客户端产品数据
 * @date 2021/7/19 9:52
 */
@RestController
@RequestMapping("/client/product")
public class ClientProductController {
    private static final Logger LOG=LoggerFactory.getLogger(ClientProductController.class);
    public static final String BUSINESS_NAME="客户端Product模块";

    @Autowired
    ProductService productService;

    @GetMapping("/list/index")
    public ResponseDataDto getIndexProduct(){
        ResponseDataDto responseData=new ResponseDataDto();
        responseData.setResponseData(productService.getIndexProduct());
        return responseData;
    }

    @GetMapping("/list")
    public ResponseDataDto getProductList(){
        ResponseDataDto responseData=new ResponseDataDto();
        responseData.setResponseData(productService.productDtoList());
        return responseData;
    }

    @PostMapping("/page/list")
    public ResponseDataDto getProductPageList(@RequestBody PageSelectDto pageSelectDto){
        ResponseDataDto responseData=new ResponseDataDto();
        LOG.info("传入的typeId：{}",pageSelectDto.getTypeId());
        if(pageSelectDto.getTypeId()!=null){
            productService.getProductPageListByTypeId(pageSelectDto);
        }else{
            productService.getProductPageDtoList(pageSelectDto);
        }
        responseData.setResponseData(pageSelectDto);
        return responseData;
    }

    //轮播产品
    @GetMapping("/carousel/list")
    public ResponseDataDto getProductCarouselList(){
        ResponseDataDto responseData=new ResponseDataDto();
        responseData.setResponseData(productService.getProductCarouselList());
        return responseData;
    }
}
